% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/NAICS_FUNCTIONS.R
\name{naics2children}
\alias{naics2children}
\title{NAICS - query NAICS codes and also see all children (subcategories) of any of those}
\usage{
naics2children(codes, allcodes = EJAM::NAICS, quiet = FALSE)
}
\arguments{
\item{codes}{vector of numerical or character}

\item{allcodes}{Optional (already loaded with package) - dataset with all the codes}

\item{quiet}{whether to avoid printing results to console}
}
\value{
vector of codes and their names
}
\description{
Used by naics_find()
}
\details{
\itemize{
\item Starts with shortest (highest level) codes. Since tied for nchar, these branches have zero overlap, so do each.
\item For each of those, get its \code{children = all} rows where \code{parentcode == substr(allcodes, 1, nchar(parentcode))}
\item Put together list of all codes we want to include so far.
\item For the next longest set of codes in original list of codes, do same thing.
\item continue until done for 5-digit ones to get 6-digit children.
\item Take the \code{unique(allthat)}
}

\code{table(nchar(as.character(NAICS)))}

\verb{   2    3    4    5    6}

\verb{  17   99  311  709 1057}
}
\examples{
  naics2children(211)
  naics_find(211, exactnumber=TRUE)
  naics_find(211, exactnumber=TRUE, add_children = TRUE)
  NAICS[211][1:3] # wrong
  NAICS[NAICS == 211]
  NAICS["211 - Oil and Gas Extraction"]

}
\seealso{
\code{\link[=naics_find]{naics_find()}} \link{NAICS}
}
